local HeroCard = class("HeroCard")

function HeroCard:ctor()
end

function HeroCard:setCallback(callback)
    self._callback = callback
end

function HeroCard:start()
    self._postEvent = self._panelTouch.gameObject:GetComponent(typeof(CS.GuidePostEvent))
    self._postEvent:SetCallback(handler(self, self._onCheckClick))
    -- G_UIUtil.addTouchEvent(self._panelTouch.transform, nil, nil, handler(self, self._onCheckClick))
end

function HeroCard:updateUI(unit)
    self._unit = unit
    local config = self._unit:getConfig()
    self._textName.text = config.name
    local heroRes = require("config.hero_res").get(config.res_id)
    self._imageHero.sprite = G_ResourceManager:loadSprite("HeroAltas", heroRes.icon)
end

function HeroCard:setCheck(isOn)
    self._check.isOn = isOn
end

function HeroCard:_onCheckClick(event)
    if event == 3 then
        if self._callback then
            self._callback(self._unit:getId())
        end
    end
end

return HeroCard
